package oldFiles;
import lejos.nxt.*;

public class Balancer {
	
	public static void main(String[] args) {
		int NEUTRAL = 52;
		int speed = 900;
		LightSensor s = new LightSensor(SensorPort.S3, true);
		Motor.B.setSpeed(speed);
		Motor.C.setSpeed(speed);
		Motor.B.flt();
		Motor.C.flt();
		
		while(!Button.ENTER.isPressed()) 
		{
			NEUTRAL = s.readNormalizedValue();
		}
		try
		{
			Thread.sleep(1000);
		}
		catch(Exception ex)
		{
		}
		
		while(!Button.ENTER.isPressed()) {
			int SENS_VAL = s.readNormalizedValue();
			
			boolean forward = SENS_VAL > NEUTRAL;
			if (forward) {
				Motor.B.forward();
				Motor.C.forward();
				
			}
			else {
				Motor.B.backward();
				Motor.C.backward();
			}
			
		}
		s.setFloodlight(false);
		Motor.B.flt();
		Motor.C.flt();
	}

}
